package com.settlement.system.controller;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.EasyExcelFactory;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.settlement.system.common.annotation.PreventDuplicateSubmit;
import com.settlement.system.common.constant.SystemConstants;
import com.settlement.system.common.result.PageResult;
import com.settlement.system.common.result.Result;
import com.settlement.system.listener.easyexcel.SysClientRegisterListener;
import com.settlement.system.model.entity.SysClientRegister;
import com.settlement.system.model.form.SysClientRegisterForm;
import com.settlement.system.model.query.SysClientRegisterQuery;
import com.settlement.system.model.vo.IndexDataVo;
import com.settlement.system.model.vo.SysClientRegisterImportVo;
import com.settlement.system.service.IndexService;
import com.settlement.system.service.SysClientRegisterService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;

/**
 * <p>
 * 客服登记表 前端控制器
 * </p>
 *
 * @author huangrensen
 * @since 2024-03-29
 */
@RestController
@RequestMapping("/api/v1/index")
@RequiredArgsConstructor
public class IndexController {

    private final IndexService indexService;

    private final RedisTemplate redisTemplate;

    @GetMapping("/getData")
    public Result<?> getData() {
        Object value = redisTemplate.opsForValue().get(SystemConstants.INDEX_DATA);
        if (value != null) {
            return Result.success((IndexDataVo)value);
        }
        IndexDataVo vo = indexService.getData();
        return Result.success(vo);
    }
}

